﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                    xmlns:params="http://schemas.codeplex.com/elysium/params"
                    xmlns:controls="clr-namespace:Framework.UI.Controls">
    <ResourceDictionary.MergedDictionaries>
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/WPF/Base/Converter.xaml" />
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/WPF/Base/Brush.xaml" />
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/WPF/Base/FocusVisualStyle.xaml"/>
        <controls:SharedResourceDictionary Source="/Framework.UI;component/Themes/ElysiumExtra/BorderFix.xaml"/>
    </ResourceDictionary.MergedDictionaries>

    <Style x:Key="ButtonsBaseStyle" TargetType="{x:Type ButtonBase}">
        <Setter Property="Background" Value="{StaticResource AccentBrush}" />
        <Setter Property="BorderBrush" Value="{StaticResource AccentBrush}" />
        <Setter Property="BorderThickness" Value="{Binding RelativeSource={RelativeSource Self},Path=(params:General.DefaultThickness),Mode=OneWay}" />
        <Setter Property="Foreground" Value="{StaticResource ContrastBrush}" />
        <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self},Path=(params:General.ContentFontSize),Mode=OneWay}" />
        <Setter Property="FontStretch" Value="Medium" />
        <Setter Property="FontStyle" Value="Normal" />
        <Setter Property="FontWeight" Value="SemiBold" />
        <Setter Property="TextOptions.TextFormattingMode" Value="Display" />
        <Setter Property="TextOptions.TextRenderingMode" Value="ClearType" />
        <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled" />
        <Setter Property="Focusable" Value="True" />
        <Setter Property="FocusVisualStyle" Value="{StaticResource {x:Static SystemParameters.FocusVisualStyleKey}}"/>
        <Setter Property="HorizontalContentAlignment" Value="Center" />
        <Setter Property="VerticalContentAlignment" Value="Center" />
        <Setter Property="Padding" Value="{Binding RelativeSource={RelativeSource Self},Path=(params:General.BoldPadding),Mode=OneWay}" />
        <Setter Property="MinWidth" Value="70" />
        <Setter Property="SnapsToDevicePixels" Value="True" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ButtonBase}">
                    <controls:BorderFix Background="{TemplateBinding Background}" 
                            BorderBrush="{TemplateBinding BorderBrush}"
                            BorderThickness="{TemplateBinding BorderThickness}"
                            TextBlock.Foreground="{TemplateBinding Foreground}" 
                            TextBlock.FontFamily="{TemplateBinding Control.FontFamily}" 
                            TextBlock.FontSize="{TemplateBinding FontSize}" 
                            TextBlock.FontStretch="{TemplateBinding FontStretch}" 
                            TextBlock.FontStyle="{TemplateBinding FontStyle}" 
                            TextBlock.FontWeight="{TemplateBinding FontWeight}" 
                            TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}" 
                            TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}" 
                            RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}" 
                            SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                        <Grid>
                            <ContentPresenter HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
                                                  Margin="{TemplateBinding Padding}" 
                                                  RecognizesAccessKey="True"
                                                  VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/>
                        </Grid>
                    </controls:BorderFix>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <DataTrigger DataTrigger.Binding="{Binding RelativeSource={RelativeSource Self},Path=FontSize,Mode=OneWay,Converter={StaticResource IsGreaterThanConverter},ConverterParameter=18}">
                <Setter Property="TextOptions.TextFormattingMode" Value="Ideal" />
            </DataTrigger>
            <Trigger Property="IsMouseOver" Value="True">
                <Setter Property="Background" Value="{StaticResource ForegroundBrush}" />
                <Setter Property="BorderBrush" Value="{StaticResource ForegroundBrush}" />
                <Setter Property="Foreground" Value="{StaticResource BackgroundBrush}" />
            </Trigger>
            <Trigger Property="IsPressed" Value="True">
                <Setter Property="Background" Value="{StaticResource LowlightBrush}" />
                <Setter Property="BorderBrush" Value="{StaticResource LowlightBrush}" />
                <Setter Property="Foreground" Value="{StaticResource BackgroundBrush}" />
            </Trigger>
            <Trigger Property="IsEnabled" Value="False">
                <Setter Property="Background" Value="{StaticResource DisabledBrush}" />
                <Setter Property="BorderBrush" Value="{StaticResource DisabledBrush}" />
                <Setter Property="Foreground" Value="{StaticResource BackgroundBrush}" />
            </Trigger>
        </Style.Triggers>
    </Style>

    <Style x:Key="{x:Type Button}" TargetType="{x:Type Button}" BasedOn="{StaticResource ButtonsBaseStyle}" >
        <Style.Triggers>
            <Trigger Property="Button.IsDefault" Value="True">
                <Setter Property="FontWeight" Value="Bold" />
            </Trigger>
        </Style.Triggers>
    </Style>
    
    <Style x:Key="HyperlinkButtonStyle" TargetType="{x:Type Button}">
        <Setter Property="Background" Value="{StaticResource TransparentBrush}"/>
        <Setter Property="BorderBrush" Value="{StaticResource AccentBrush}"/>
        <Setter Property="BorderThickness" Value="0, 0, 0, 3"/>
        <Setter Property="Cursor" Value="Hand"/>
        <Setter Property="FocusVisualStyle" Value="{StaticResource {x:Static SystemParameters.FocusVisualStyleKey}}"/>
        <Setter Property="HorizontalContentAlignment" Value="Left"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.HeaderFontSize)}"/>
        <Setter Property="FontStretch" Value="Medium"/>
        <Setter Property="FontStyle" Value="Normal"/>
        <Setter Property="FontWeight" Value="Normal"/>
        <Setter Property="TextOptions.TextFormattingMode" Value="Display"/>
        <Setter Property="TextOptions.TextRenderingMode" Value="ClearType"/>
        <Setter Property="RenderOptions.ClearTypeHint" Value="Enabled"/>
        <Setter Property="Focusable" Value="True"/>
        <Setter Property="Foreground" Value="{StaticResource ForegroundBrush}"/>
        <Setter Property="OverridesDefaultStyle" Value="True"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="SnapsToDevicePixels" Value="True"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Button}">
                    <ControlTemplate.Resources>
                        <Storyboard x:Key="MouseEnter">
                            <DoubleAnimation Duration="00:00:00.3"
                                             Storyboard.TargetName="Border"
                                             Storyboard.TargetProperty="Opacity"
                                             To="1"/>
                        </Storyboard>
                        <Storyboard x:Key="MouseLeave">
                            <DoubleAnimation Duration="00:00:00.3"
                                             Storyboard.TargetName="Border"
                                             Storyboard.TargetProperty="Opacity"/>
                        </Storyboard>
                    </ControlTemplate.Resources>
                    <Grid>
                        <controls:BorderFix x:Name="Border"
                                BorderBrush="{TemplateBinding BorderBrush}"
                                BorderThickness="{TemplateBinding BorderThickness}"
                                Opacity="0"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                        <Border Background="{TemplateBinding Background}"
                                TextBlock.Foreground="{TemplateBinding Foreground}"
                                TextBlock.FontFamily="{TemplateBinding FontFamily}"
                                TextBlock.FontSize="{TemplateBinding FontSize}"
                                TextBlock.FontStretch="{TemplateBinding FontStretch}"
                                TextBlock.FontStyle="{TemplateBinding FontStyle}"
                                TextBlock.FontWeight="{TemplateBinding FontWeight}"
                                TextOptions.TextFormattingMode="{TemplateBinding TextOptions.TextFormattingMode}"
                                TextOptions.TextRenderingMode="{TemplateBinding TextOptions.TextRenderingMode}"
                                RenderOptions.ClearTypeHint="{TemplateBinding RenderOptions.ClearTypeHint}"
                                SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}">
                            <ContentPresenter Margin="{TemplateBinding Padding}"
                                              HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}"
                                              VerticalAlignment="{TemplateBinding VerticalContentAlignment}"
                                              RecognizesAccessKey="True"/>
                        </Border>
                    </Grid>
                    <ControlTemplate.Triggers>
                        <Trigger Property="IsDefault" Value="True">
                            <Setter Property="FontWeight" Value="Bold"/>
                        </Trigger>
                        <Trigger Property="IsEnabled" Value="False">
                            <Setter Property="Foreground" Value="{StaticResource DisabledBrush}"/>
                        </Trigger>
                        <Trigger Property="IsMouseOver" Value="True">
                            <Trigger.EnterActions>
                                <StopStoryboard BeginStoryboardName="MouseLeave"/>
                                <BeginStoryboard x:Name="MouseEnter" Storyboard="{StaticResource MouseEnter}"/>
                            </Trigger.EnterActions>
                            <Trigger.ExitActions>
                                <StopStoryboard BeginStoryboardName="MouseEnter"/>
                                <BeginStoryboard x:Name="MouseLeave" Storyboard="{StaticResource MouseLeave}"/>
                            </Trigger.ExitActions>
                        </Trigger>
                    </ControlTemplate.Triggers>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>
    <Style x:Key="NormalTextHyperlinkButtonStyle" BasedOn="{StaticResource HyperlinkButtonStyle}" TargetType="{x:Type Button}">
        <Setter Property="FontSize" Value="{Binding RelativeSource={RelativeSource Self}, Path=(params:General.TextFontSize)}"/>
    </Style>

</ResourceDictionary>